<template>
  <div class="app-container">
    <div class="filter-container">
      <el-date-picker
        v-model="dateRange"
        value-format="yyyy-MM-dd HH:mm:ss"
        type="datetimerange"
        range-separator="~"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        :editable="false"
        class="filter-item"
        @change="changeDate"
      />
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
      <el-button v-if="type == 0" v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">导出</el-button>
    </div>
    <el-tabs v-model="activeName" type="border-card">
      <el-tab-pane :key="'0'" :label="'全部'">
        <el-table v-loading="listLoading" :show-header="false" :data="metaListAll" border fit highlight-current-row style="width: 100%;">
          <el-table-column>
            <el-table :data="metaListAll" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="总体统计" align="center">
                <el-table-column label="总识别车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="通过车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="拒绝车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total2 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="系统识别次数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.totalAll1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="拒绝次数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.totalAll2 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
            <el-table :data="refuseListAll" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="拒绝车辆统计" align="center">
                <el-table-column label="非返场车" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="返回超时" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse2 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="距离不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse5 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="次数不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse3 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="无订单" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse6 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="订单时间不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse4 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="黑名单" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse8 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="白名单超次" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse11 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
            <el-table :data="exportListAll" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="通过车辆统计" align="center">
                <el-table-column label="短途通过" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse0 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="白名单通过" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse10 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane :key="'1'" :label="'详细'">
        <el-table :show-header="false" :data="metaList0" border fit highlight-current-row style="width: 100%;">
          <el-table-column align="center" width="200">
            <template>
              <span>南蓄</span>
            </template>
          </el-table-column>
          <el-table-column>
            <el-table :data="metaList0" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="总体统计" align="center">
                <el-table-column label="总识别车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="通过车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="拒绝车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total2 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="系统识别次数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.totalAll1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="拒绝次数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.totalAll2 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
            <el-table :data="refuseList0" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="拒绝车辆统计" align="center">
                <el-table-column label="非返场车" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="返回超时" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse2 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="距离不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse5 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="次数不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse3 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="无订单" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse6 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="订单时间不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse4 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="黑名单" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse8 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="白名单超次" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse11 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
            <el-table :data="exportList0" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="通过车辆统计" align="center">
                <el-table-column label="短途通过" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse0 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="白名单通过" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse10 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
          </el-table-column>
        </el-table>
        <el-table :show-header="false" :data="metaList1" border fit highlight-current-row style="width: 100%;">
          <el-table-column align="center" width="200">
            <template>
              <span>北蓄</span>
            </template>
          </el-table-column>
          <el-table-column>
            <el-table :data="metaList1" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="总体统计" align="center">
                <el-table-column label="总识别车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="通过车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="拒绝车辆数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.total2 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="系统识别次数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.totalAll1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="拒绝次数" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.totalAll2 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
            <el-table :data="refuseList1" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="拒绝车辆统计" align="center">
                <el-table-column label="非返场车" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="返回超时" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse2 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="距离不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse5 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="次数不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse3 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="无订单" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse6 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="订单时间不符" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse4 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="黑名单" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse8 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="白名单超次" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse11 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
            <el-table :data="exportList1" border fit highlight-current-row style="width: 100%;">
              <el-table-column label="通过车辆统计" align="center">
                <el-table-column label="短途通过" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse0 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="白名单通过" align="center">
                  <template slot-scope="{ row }">
                    <span>{{ row.refuse10 }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { getShortdistanceTotal } from '@/api/shortdistance';
import waves from '@/directive/waves';
import { parseTime } from '@/utils';

var that;

export default {
  name: 'Shortdistance',
  directives: { waves },
  filters: {
    parkingNoFilter(item) {
      const parkingNoKeyValue = that.parkingNoOptions.reduce((acc, cur) => {
        acc[cur.key] = cur.label;
        return acc;
      }, {});
      return parkingNoKeyValue[item];
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      downloadLoading: false,
      listQuery: {
        beginTime: '',
        endTime: ''
      },
      dateRange: [],
      parkingNoOptions: [{ label: '南蓄', key: 0 }, { label: '北蓄', key: 1 }],
      metaListAll: null,
      metaList0: null,
      metaList1: null,
      refuseListAll: null,
      refuseList0: null,
      refuseList1: null,
      exportListAll: null,
      exportList0: null,
      exportList1: null,
      type: null,
      activeName: '0'
    };
  },
  created() {
    that = this;
    const { params } = this.$route
    Object.keys(params).forEach(key => {
      this.type = params[key].split(':')[1];
    });
    this.dateRange.push(parseTime(new Date(), '{y}-{m}-{d}') + ' 00:00:00');
    this.dateRange.push(parseTime(new Date(), '{y}-{m}-{d}') + ' 23:59:59');
    this.listQuery.beginTime = this.dateRange[0] + ' 00:00:00';
    this.listQuery.endTime = this.dateRange[1] + ' 23:59:59';
    this.getList();
  },
  methods: {
    async getList() {
      this.metaListAll = [];
      this.metaList0 = [];
      this.metaList1 = [];
      this.refuseListAll = [];
      this.refuseList0 = [];
      this.refuseList1 = [];
      this.exportListAll = [];
      this.exportList0 = [];
      this.exportList1 = [];
      this.listLoading = true;
      await getShortdistanceTotal(this.listQuery).then(response => {
        this.list = response.data;
        // 南蓄
        var list0 = this.list.filter(e => {
          return e.parkingNo === 0
        });
        if (list0[0].meta) {
          this.metaList0.push(list0[0].meta)
        } else {
          var obj0 = {
            total: 0,
            total1: 0,
            total2: 0,
            totalAll1: 0,
            totalAll2: 0
          }
          this.metaList0.push(obj0)
        }
        // 拒绝统计分类
        var refuse0List = list0[0].typeList.filter(e => {
          return e.recType === 2
        });
        var refuse0 = {
          refuse1: 0,
          refuse2: 0,
          refuse3: 0,
          refuse4: 0,
          refuse5: 0,
          refuse6: 0,
          refuse8: 0,
          refuse11: 0
        };
        if (refuse0List.length > 0) {
          var refuseS1 = refuse0List.filter(e => {
            return e.refuseType === 1
          })
          var refuseS2 = refuse0List.filter(e => {
            return e.refuseType === 2
          })
          var refuseS3 = refuse0List.filter(e => {
            return e.refuseType === 3
          })
          var refuseS4 = refuse0List.filter(e => {
            return e.refuseType === 4
          })
          var refuseS5 = refuse0List.filter(e => {
            return e.refuseType === 5
          })
          var refuseS6 = refuse0List.filter(e => {
            return e.refuseType === 6
          })
          var refuseS7 = refuse0List.filter(e => {
            return e.refuseType === 7
          })
          var refuseS8 = refuse0List.filter(e => {
            return e.refuseType === 8
          })
          var refuseS11 = refuse0List.filter(e => {
            return e.refuseType === 11
          })
          if (refuseS1.length > 0) {
            refuse0.refuse1 = refuseS1[0].total;
          }
          if (refuseS2.length > 0) {
            refuse0.refuse2 = refuseS2[0].total;
          }
          if (refuseS3.length > 0) {
            refuse0.refuse3 = refuseS3[0].total;
          }
          if (refuseS4.length > 0) {
            refuse0.refuse4 = refuseS4[0].total;
          }
          if (refuseS5.length > 0) {
            refuse0.refuse5 = refuseS5[0].total;
          }
          if (refuseS6.length > 0) {
            refuse0.refuse6 = refuseS6[0].total;
          }
          if (refuseS7.length > 0) {
            refuse0.refuse6 = Number(refuse0.refuse6) + Number(refuseS7[0].total);
          }
          if (refuseS8.length > 0) {
            refuse0.refuse8 = refuseS8[0].total;
          }
          if (refuseS11.length > 0) {
            refuse0.refuse11 = refuseS11[0].total;
          }
        }
        this.refuseList0.push(refuse0)
        // 通行统计分类
        var export0List = list0[0].typeList.filter(e => {
          return e.recType === 1
        });
        var export0 = {
          refuse0: 0,
          refuse10: 0
        };
        if (export0List.length > 0) {
          var refuseS0 = export0List.filter(e => {
            return e.refuseType === 0
          })
          var refuseS10 = export0List.filter(e => {
            return e.refuseType === 10
          })
          if (refuseS0.length > 0) {
            export0.refuse0 = refuseS0[0].total;
          }
          if (refuseS10.length > 0) {
            export0.refuse10 = refuseS10[0].total;
          }
        }
        this.exportList0.push(export0)

        // 北蓄
        var list1 = this.list.filter(e => {
          return e.parkingNo === 1
        });
        if (list1[0].meta) {
          this.metaList1.push(list1[0].meta)
        } else {
          var obj1 = {
            total: 0,
            total1: 0,
            total2: 0,
            totalAll1: 0,
            totalAll2: 0
          }
          this.metaList1.push(obj1)
        }
        // 拒绝统计分类
        var refuse1List = list1[0].typeList.filter(e => {
          return e.recType === 2
        });
        var refuse1 = {
          refuse1: 0,
          refuse2: 0,
          refuse3: 0,
          refuse4: 0,
          refuse5: 0,
          refuse6: 0,
          refuse8: 0,
          refuse11: 0
        };
        if (refuse1List.length > 0) {
          var refuseN1 = refuse1List.filter(e => {
            return e.refuseType === 1
          })
          var refuseN2 = refuse1List.filter(e => {
            return e.refuseType === 2
          })
          var refuseN3 = refuse1List.filter(e => {
            return e.refuseType === 3
          })
          var refuseN4 = refuse1List.filter(e => {
            return e.refuseType === 4
          })
          var refuseN5 = refuse1List.filter(e => {
            return e.refuseType === 5
          })
          var refuseN6 = refuse1List.filter(e => {
            return e.refuseType === 6
          })
          var refuseN7 = refuse1List.filter(e => {
            return e.refuseType === 7
          })
          var refuseN8 = refuse1List.filter(e => {
            return e.refuseType === 8
          })
          var refuseN11 = refuse1List.filter(e => {
            return e.refuseType === 11
          })
          if (refuseN1.length > 0) {
            refuse1.refuse1 = refuseN1[0].total;
          }
          if (refuseN2.length > 0) {
            refuse1.refuse2 = refuseN2[0].total;
          }
          if (refuseN3.length > 0) {
            refuse1.refuse3 = refuseN3[0].total;
          }
          if (refuseN4.length > 0) {
            refuse1.refuse4 = refuseN4[0].total;
          }
          if (refuseN5.length > 0) {
            refuse1.refuse5 = refuseN5[0].total;
          }
          if (refuseN6.length > 0) {
            refuse1.refuse6 = refuseN6[0].total;
          }
          if (refuseN7.length > 0) {
            refuse1.refuse6 = Number(refuse1.refuse6) + Number(refuseN7[0].total);
          }
          if (refuseN8.length > 0) {
            refuse1.refuse8 = refuseN8[0].total;
          }
          if (refuseN11.length > 0) {
            refuse1.refuse11 = refuseN11[0].total;
          }
        }
        this.refuseList1.push(refuse1)
        // 通行统计分类
        var export1List = list1[0].typeList.filter(e => {
          return e.recType === 1
        });
        var export1 = {
          refuse0: 0,
          refuse10: 0
        };
        if (export1List.length > 0) {
          var refuseN0 = export1List.filter(e => {
            return e.refuseType === 0
          })
          var refuseN10 = export1List.filter(e => {
            return e.refuseType === 10
          })
          if (refuseN0.length > 0) {
            export1.refuse0 = refuseN0[0].total;
          }
          if (refuseN10.length > 0) {
            export1.refuse10 = refuseN10[0].total;
          }
        }
        this.exportList1.push(export1)

        // 总计
        var objAll = {
          total: 0,
          total1: 0,
          total2: 0,
          totalAll1: 0,
          totalAll2: 0
        }
        objAll.total = Number(this.metaList0[0].total) + Number(this.metaList1[0].total);
        objAll.total1 = Number(this.metaList0[0].total1) + Number(this.metaList1[0].total1);
        objAll.total2 = Number(this.metaList0[0].total2) + Number(this.metaList1[0].total2);
        objAll.totalAll1 = Number(this.metaList0[0].totalAll1) + Number(this.metaList1[0].totalAll1);
        objAll.totalAll2 = Number(this.metaList0[0].totalAll2) + Number(this.metaList1[0].totalAll2);
        this.metaListAll.push(objAll);

        var refuseAll = {
          refuse1: 0,
          refuse2: 0,
          refuse3: 0,
          refuse4: 0,
          refuse5: 0,
          refuse6: 0,
          refuse8: 0,
          refuse11: 0
        };
        refuseAll.refuse1 = Number(this.refuseList0[0].refuse1) + Number(this.refuseList1[0].refuse1);
        refuseAll.refuse2 = Number(this.refuseList0[0].refuse2) + Number(this.refuseList1[0].refuse2);
        refuseAll.refuse3 = Number(this.refuseList0[0].refuse3) + Number(this.refuseList1[0].refuse3);
        refuseAll.refuse4 = Number(this.refuseList0[0].refuse4) + Number(this.refuseList1[0].refuse4);
        refuseAll.refuse5 = Number(this.refuseList0[0].refuse5) + Number(this.refuseList1[0].refuse5);
        refuseAll.refuse6 = Number(this.refuseList0[0].refuse6) + Number(this.refuseList1[0].refuse6);
        refuseAll.refuse8 = Number(this.refuseList0[0].refuse8) + Number(this.refuseList1[0].refuse8);
        refuseAll.refuse11 = Number(this.refuseList0[0].refuse11) + Number(this.refuseList1[0].refuse11);
        this.refuseListAll.push(refuseAll);

        var exportAll = {
          refuse0: 0,
          refuse10: 0
        };
        exportAll.refuse0 = Number(this.exportList0[0].refuse0) + Number(this.exportList1[0].refuse0);
        exportAll.refuse10 = Number(this.exportList0[0].refuse10) + Number(this.exportList1[0].refuse10);
        this.exportListAll.push(exportAll);

        this.listLoading = false;
      });
    },
    async handleSearch() {
      this.getList();
    },
    changeDate(val) {
      if (val) {
        this.listQuery.beginTime = val[0];
        this.listQuery.endTime = val[1];
      } else {
        this.listQuery.beginTime = null;
        this.listQuery.endTime = null;
      }
    },
    async handleDownload() {
      this.list = [];
      this.downloadLoading = true;
      await getShortdistanceTotal(this.listQuery).then(response => {
        var obj0 = {
          parkingNo: 0,
          total: 0,
          total1: 0,
          total2: 0,
          totalAll1: 0,
          totalAll2: 0,
          refuse0: 0,
          refuse1: 0,
          refuse2: 0,
          refuse3: 0,
          refuse4: 0,
          refuse5: 0,
          refuse6: 0,
          refuse8: 0,
          refuse10: 0,
          refuse11: 0,
          beginTime: null,
          endTime: null
        }
        // 南蓄
        var list0 = response.data.filter(e => {
          return e.parkingNo === 0
        });
        if (list0[0].meta) {
          obj0.total = list0[0].meta.total
          obj0.total1 = list0[0].meta.total1
          obj0.total2 = list0[0].meta.total2
          obj0.totalAll1 = list0[0].meta.totalAll1
          obj0.totalAll2 = list0[0].meta.totalAll2
        }
        for (var n = 0; n < list0[0].typeList.length; n++) {
          var item = list0[0].typeList[n]
          if (item.recType === 1) {
            if (item.refuseType === 0) {
              obj0.refuse0 = item.total
            } else if (item.refuseType === 10) {
              obj0.refuse10 = item.total
            }
          } else if (item.recType === 2) {
            if (item.refuseType === 1) {
              obj0.refuse1 = item.total
            } else if (item.recType === 2) {
              obj0.refuse2 = item.total
            } else if (item.recType === 3) {
              obj0.refuse3 = item.total
            } else if (item.recType === 4) {
              obj0.refuse4 = item.total
            } else if (item.recType === 5) {
              obj0.refuse5 = item.total
            } else if (item.recType === 6) {
              obj0.refuse6 = item.total
            } else if (item.recType === 7) {
              obj0.refuse6 = Number(obj0.refuse6) + Number(item.total)
            } else if (item.recType === 8) {
              obj0.refuse8 = item.total
            } else if (item.recType === 11) {
              obj0.refuse6 = item.total
            }
          }
        }
        if (this.dateRange && this.dateRange.length > 1) {
          obj0.beginTime = this.dateRange[0]
          obj0.endTime = this.dateRange[1]
        }
        this.list.push(obj0)

        var obj1 = {
          parkingNo: 1,
          total: 0,
          total1: 0,
          total2: 0,
          totalAll1: 0,
          totalAll2: 0,
          refuse0: 0,
          refuse1: 0,
          refuse2: 0,
          refuse3: 0,
          refuse4: 0,
          refuse5: 0,
          refuse6: 0,
          refuse8: 0,
          refuse10: 0,
          refuse11: 0,
          beginTime: null,
          endTime: null
        }
        // 北蓄
        var list1 = response.data.filter(e => {
          return e.parkingNo === 1
        });
        if (list1[0].meta) {
          obj1.total = list1[0].meta.total
          obj1.total1 = list1[0].meta.total1
          obj1.total2 = list1[0].meta.total2
          obj1.totalAll1 = list1[0].meta.totalAll1
          obj1.totalAll2 = list1[0].meta.totalAll2
        }
        for (var m = 0; m < list1[0].typeList.length; m++) {
          var item1 = list1[0].typeList[m]
          if (item1.recType === 1) {
            if (item1.refuseType === 0) {
              obj1.refuse0 = item1.total
            } else if (item1.refuseType === 10) {
              obj1.refuse10 = item1.total
            }
          } else if (item1.recType === 2) {
            if (item1.refuseType === 1) {
              obj1.refuse1 = item1.total
            } else if (item1.recType === 2) {
              obj1.refuse2 = item1.total
            } else if (item1.recType === 3) {
              obj1.refuse3 = item1.total
            } else if (item1.recType === 4) {
              obj1.refuse4 = item1.total
            } else if (item1.recType === 5) {
              obj1.refuse5 = item1.total
            } else if (item1.recType === 6) {
              obj1.refuse6 = item1.total
            } else if (item1.recType === 7) {
              obj1.refuse6 = Number(obj1.refuse6) + Number(item1.total)
            } else if (item1.recType === 8) {
              obj1.refuse8 = item1.total
            } else if (item1.recType === 11) {
              obj1.refuse6 = item1.total
            }
          }
        }

        if (this.dateRange && this.dateRange.length > 1) {
          obj1.beginTime = this.dateRange[0]
          obj1.endTime = this.dateRange[1]
        }
        this.list.push(obj1)

        // 总计
        var objAll = {
          parkingNo: null,
          total: 0,
          total1: 0,
          total2: 0,
          totalAll1: 0,
          totalAll2: 0,
          refuse0: 0,
          refuse1: 0,
          refuse2: 0,
          refuse3: 0,
          refuse4: 0,
          refuse5: 0,
          refuse6: 0,
          refuse8: 0,
          refuse10: 0,
          refuse11: 0,
          beginTime: null,
          endTime: null
        }
        objAll.total = Number(obj0.total) + Number(obj1.total);
        objAll.total1 = Number(obj0.total1) + Number(obj1.total1);
        objAll.total2 = Number(obj0.total2) + Number(obj1.total2);
        objAll.totalAll1 = Number(obj0.totalAll1) + Number(obj1.totalAll1);
        objAll.totalAll2 = Number(obj0.totalAll2) + Number(obj1.totalAll2);
        objAll.refuse0 = Number(obj0.refuse0) + Number(obj1.refuse0);
        objAll.refuse1 = Number(obj0.refuse1) + Number(obj1.refuse1);
        objAll.refuse2 = Number(obj0.refuse2) + Number(obj1.refuse2);
        objAll.refuse3 = Number(obj0.refuse3) + Number(obj1.refuse3);
        objAll.refuse4 = Number(obj0.refuse4) + Number(obj1.refuse4);
        objAll.refuse5 = Number(obj0.refuse5) + Number(obj1.refuse5);
        objAll.refuse6 = Number(obj0.refuse6) + Number(obj1.refuse6);
        objAll.refuse8 = Number(obj0.refuse8) + Number(obj1.refuse8);
        objAll.refuse10 = Number(obj0.refuse10) + Number(obj1.refuse10);
        objAll.refuse11 = Number(obj0.refuse11) + Number(obj1.refuse11);
        if (this.dateRange && this.dateRange.length > 1) {
          objAll.beginTime = this.dateRange[0]
          objAll.endTime = this.dateRange[1]
        }
        this.list.push(objAll)

        import('@/vendor/Export2Excel').then(excel => {
          const tHeader = ['蓄车场', '总识别车辆数', '通过车辆数', '拒绝车辆数', '系统识别次数', '拒绝次数', '非返场车', '返回超时', '距离不符', '次数不符', '无订单', '订单时间不符', '黑名单', '白名单超次', '短途通过', '白名单通过', '开始时间', '结束时间'];
          const filterVal = ['parkingNo', 'total', 'total1', 'total2', 'totalAll1', 'totalAll2', 'refuse1', 'refuse2', 'refuse5', 'refuse3', 'refuse6', 'refuse4', 'refuse8', 'refuse11', 'refuse0', 'refuse10', 'beginTime', 'endTime'];
          const data = this.formatJson(this.list, filterVal);
          excel.export_json_to_excel({
            header: tHeader,
            data,
            filename: '通行和拒绝量统计'
          });
          this.downloadLoading = false;
          this.$message({
            message: '通行和拒绝量统计导出成功',
            type: 'success'
          });
        });
      });
    },
    formatJson(list, filterVal) {
      const typeFilter = this.$options.filters['parkingNoFilter'];
      return list.map(v =>
        filterVal.map(j => {
          if (j === 'parkingNo') {
            return typeFilter(v[j]);
          } else if (j === 'beginTime' || j === 'endTime') {
            return parseTime(v[j], '{y}-{m}-{d} {h}:{i}:{s}');
          } else {
            return v[j];
          }
        })
      );
    }
  }
};
</script>
